<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
	layout:decorator="admin/fragments/layout"
	th:with="title='角色编辑',active='role'">

<section layout:fragment="header">
	<h1>角色编辑</h1>
</section>

<section layout:fragment="content">
	<div class="row">
		<div class="col-md-12">
			<div class="box  box-primary">
				<form class="form-horizontal form-edit" method="post">
					<div class="box-body">
						<input type="hidden" id="id" name="id"
							th:value="${role==null?'':role.id}" />
						<div class="form-group">
							<label class="col-sm-2 control-label">角色名称：</label>
							<div class="col-sm-10">
								<input id="roleName" name="roleName"
									th:value="${role==null?'':role.roleName}" class="form-control"
									type="text" />
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">资源key：</label>
							<div class="col-sm-10">
								<input id="roleKey" name="roleKey"
									th:value="${role==null?'':role.roleKey}" class="form-control"
									type="text" />
							</div>
						</div>
					</div>
					<div class="box-footer">
						<a type="button" class="btn btn-default btn-back"
							href="/admin/role/">返回</a>
						<button type="button" class="btn btn-info pull-right btn-submit">提交</button>
					</div>
				</form>
			</div>
		</div>
	</div>
</section>


<script layout:fragment="script">
	$(".btn-submit").click(function() {
		$.ajax({
			type : "POST",
			url : "/admin/role/edit",
			data : $(".form-edit").serialize(),
			dataType : "JSON",
			success : function(res) {
				layer.msg(res.message, {
					time : 2000
				}, function() {
					location.reload();
				});
			}
		});
	});
</script>
</html>